﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
using Enterprise.Model.Note;
using Enterprise.Infrastructure;
namespace Enterprise.Data.Note
{
    /// <summary>
    /// 个人备忘or记事
    /// </summary>
    public class NoteData
    {
        /// <summary>
        ///  个人备忘or记事数据列表
        /// </summary>
        /// <returns></returns>
        public List<NoteEntity> NoteList()
        {
            List<NoteEntity> list = new List<NoteEntity>();
            string cmd = "Select * from SYS_NOTE";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                NoteEntity entity = new NoteEntity();
                if (!Convert.IsDBNull(dr["NOTEID"])) entity.NOTEID = Convert.ToInt32(dr["NOTEID"]);
                if (!Convert.IsDBNull(dr["NTITLE"])) entity.NTITLE = Convert.ToString(dr["NTITLE"]);
                if (!Convert.IsDBNull(dr["NREMARK"])) entity.NREMARK = Convert.ToString(dr["NREMARK"]);
                if (!Convert.IsDBNull(dr["NISREMIND"])) entity.NISREMIND = Convert.ToInt32(dr["NISREMIND"]);
                if (!Convert.IsDBNull(dr["NREMINDUSERS"])) entity.NREMINDUSERS = Convert.ToString(dr["NREMINDUSERS"]);
                if (!Convert.IsDBNull(dr["NREMINDTIME"])) entity.NREMINDTIME = Convert.ToDateTime(dr["NREMINDTIME"]);
                if (!Convert.IsDBNull(dr["NREMINDTYPE"])) entity.NREMINDTYPE = Convert.ToString(dr["NREMINDTYPE"]);
                if (!Convert.IsDBNull(dr["NUSERID"])) entity.NUSERID = Convert.ToInt32(dr["NUSERID"]);
                if (!Convert.IsDBNull(dr["NCREATETIME"])) entity.NCREATETIME = Convert.ToDateTime(dr["NCREATETIME"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void Execute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

        /// <summary>
        /// 返回数据集合
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public DataSet ExcuteDataSet(string cmd)
        {
            return DbExecute.GetDataSet(cmd);
        }
    }
}
